package com.hnzq.cloud.freshorderassembly.controller;


import com.hnzq.cloud.GoodsOrderAPI;
import com.hnzq.cloud.dto.FreGoodsOrder;
import com.hnzq.cloud.freshorderassembly.service.IFreGoodsOrderService;
import com.hnzq.cloud.model.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 周皓月
 * @since 2022-02-06
 */
@RestController
@RequestMapping("/freGoodsOrder")
public class FreGoodsOrderController implements GoodsOrderAPI {

    @Autowired
    private IFreGoodsOrderService gos;

    /**
     * 查询所有的订单商品（中间表）
     * @return
     */
    @Override
    public Result<List<FreGoodsOrder>> findAllGoodsOrder() {
        return Result.newInstance().setMessage("查询成功").setData(gos.findAllGoodsOrder());
    }

    /**
     * 根据单个订单id查询
     * @param orderId
     * @return
     */
    @Override
    public Result<List<FreGoodsOrder>> findGoodsOrderByOrderId(Integer orderId) {
        return Result.newInstance().setMessage("查询成功").setData(gos.findGoodsOrderByOrderId(orderId));
    }
}

